package com.song.dp.config;

import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc;

/**
 * @author TonySong
 * @date 2024/8/8 0008
 * @time 15:02
 */
@Configuration
@EnableKnife4j
@EnableSwagger2WebMvc
public class Kinf4JConfig {

    @Bean(value = "defaultApi2")
    public Docket defaultApi2() {
        Docket docket=new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                //分组名称
                .groupName("1.0")
                .select()
                //这里指定Controller扫描包路径
                .apis(RequestHandlerSelectors.basePackage("com.song.dp"))
                //过滤掉knife4j的接口
                .paths(PathSelectors.any())
                .build();
        return docket;
    }
    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                //页面标题
                .title("振涛点评API文档")
                //文档描述
                .description("振涛点评API文档")
                //文档服务器的地址
                .termsOfServiceUrl("http://www.song.com")
                //作者信息
                .contact(new Contact("振涛头条", "http://www.song.com", "lyhxr@example.com"))
                //版本号
                .version("1.0")
                .build();
    }




}